 <meta charset="utf-8">
 <div class="card" id="biz_aIConfigCate_conatainer" style="padding-bottom: 0px;">
 
   
 <div class="card">
 	<div class="card-body">
 	<div class="row">
 	
 	  <div class="col-md-3">
             <div class="table-responsive">
                                            <table class="table mb-0">
                                                <thead>
                                                    <tr>
                                                        <th><div class="alert alert-danger mb-0" role="alert">当前设备：<strong>【{{device.name}}】</strong><br>针对每个算法请单独保存！</div></th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <tr v-for="(cate,index) in cateList">
                                                        <td><button class="btn btn-outline btn-primary btn-block" v-on:click="loadItemValues(cate)">{{cate.name}}</button></td>
                                                    </tr>
                                                </tbody>
                                            </table>
             </div>
 	  </div>
 	  
 	  
 	  <div class="col-md-9">
 	  
 	  						<div class="alert alert-warning" role="alert" v-if="nowcate.name">
                                          		    当前选择配置类别：<font color="red"><strong>【{{nowcate.name}}】</strong></font> <strong>请注意保存后再点击左侧配置类别进行切换！！！</strong> 
                                          		    
                                   <button type="button"  v-kperms="{perm:''}" class="btn btn-info float-right" style="margin-top:-7px;" v-on:click="save()">
                                        <i class="ti-save" aria-hidden="true" ></i> 保存
                                    </button>
                           </div>
                                            
           

  									<div class="table-responsive" id="itemTableContainer" style="overflow: scroll;max-height: 1500px;">
                                            <table class="table mb-0">
                                                <thead>
                                                    <tr>
                                                        <th>#</th>
                                                        <th>编码</th>
                                                        <th>名称</th>
                                                        <th>配置值</th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <tr  v-for="(item,index) in itemValueList">
                                                        <th scope="row">{{index+1}}</th>
                                                        <td>{{item.itemCode}}</td>
                                                        <td>{{item.itemName}}</td>
                                                        <td>
                                                       	 	<textarea rows="2" cols="90" v-model="item.cofvalue"></textarea>
                                                        </td>
                                                    </tr>
                                                   
                                                </tbody>
                                            </table>
                                        </div>
                                        
                           
                                        
                                        
 	  </div>
 	</div>
 	</div>
 	</div>
 	
 </div>
<script>
var anewaz=new Vue({  
	  el: '#biz_aIConfigCate_conatainer', 
	  data:{
		  searchForm:{
			  name: null,
			  status: null
		  },
		  nowcate:{},
		  cateList:[],
		  itemValueList:[],
		  device:{},
		  maxh:500,
	      bus:new Vue()
	  },
	  mounted:function(){
		 var _this=this;
		 var param=zfesLayerEditDg.getLayerParam();
		 _this.maxh=param.maxhz;
		 layer.full(layer.index);
		 _this.loadDevice(param.deviceId);
		 
		// _this.initCateTable();
		 _this.initAlgorithmTable();
		 $("#itemTableContainer").height(_this.maxh);
		// _this.maxh=param.maxh;
	  },

    methods: {
    	loadDevice: function(did){
   		 var _this=this;
   		 var url="/xzy/device/loadDevice";
       	 var param=zfesLayerEditDg.getLayerParam();
   		 zfesAjax.ajaxTodo(url,{id:did}, function(data){
       		 _this.device=data.data.device;
       	 })
		},
		 initAlgorithmTable: function(){
	  		 var　_this=this;
	  		 var url="/manger/algorithm/loadAllAlgorithm";
			    zfesAjax.ajaxTodo(url, {"status":1}, function(data) {
					_this.cateList=data.data.algorithmList;
					if(_this.cateList&&_this.cateList.length>0){
						_this.loadItemValues(_this.nowcate);
					}
					
				});
	 	 },
     	 initCateTable: function(){
      		 var　_this=this;
      		 var url="/xzy/aIConfigCate/loadAllAIConfigCate";
      		
 		    zfesAjax.ajaxTodo(url, {"status":1}, function(data) {
 				_this.cateList=data.data.cateList;
 				if(_this.cateList&&_this.cateList.length>0){
 					
 					_this.loadItemValues(_this.cateList[0]);
 				}
 				
 			});
     	 },
     	 
     	loadItemValues: function(cate){
     		 var _this=this;
     		
     		 if(_this.nowcate.id==cate.id){
     			 return;
     		 }
     		 _this.nowcate=cate;
     		 var url="/xzy/aIConfigItemValue/loadAIConfigItemValueList";
     		zfesAjax.ajaxTodo(url, {cateId:cate.id,deviceId:_this.device.id}, function(data) {
 				_this.itemValueList=data.data.itemValueList;
 			});
     	},
  	 
	  refresh:function(){
		  var　_this=this;
		  _this.loadItemValues(_this.nowcate);
	  },
	  
  	save: function(){
 		 var　_this=this;
 		 console.log(_this.itemValueList);
 		 $.ajax({
             type: "POST",
             url: "/xzy/aIConfigItemValue/saveItemValues?cateId="+_this.nowcate.id+"&deviceId="+_this.device.id+"",
             contentType: "application/json;charset=utf-8",
             data:JSON.stringify(_this.itemValueList),
             dataType: "json",
             success:function (message) {
                if(message.statusCode==200){
                	alertSwal.successText(message.message);
                }else{
                	alertSwal.warningText(message.message);
                }
             },
             error:function (message) {
            	 alertSwal.warningText(message);
             }
         });
 		 
 	  },
 	
	  
   	
   }

});

function showDetail(row){
	anewaz.showDetail(row);
}
</script>


